<?php
error_reporting(0);
session_start();

include_once "src/model/Consultant.php";
include_once "src/controller/regmanagement/AccountManager.php";

try {
    if (!isset($_SESSION["email"])) {
        if (($_POST["activateCreateUserAccount"] != "1") && ($_POST["activateLogInUserAccount"] != "1")) {
            include "includes/accessDeniedInclude.php";
        }

        if ($_POST["activateLogInUserAccount"] == "1") {
            if (AccountManager::isValidLogIn($_POST['username'], $_POST['logInPassword'])) {
                $_SESSION["userFullName"] = AccountManager::getUserFullName($_POST['username']);
                $_SESSION["email"] = $_POST['username'];
            }
        }

        if ($_POST["activateCreateUserAccount"] == "1") {
            $firstName = $_POST["firstName"];
            $lastName = $_POST["lastName"];
            $email = $_POST["email"];
            $password = $_POST["password"];

            try {
                AccountManager::createUserAccount($firstName, $lastName, $email, $password);
                $_SESSION["userFullName"] = $_POST["firstName"] . " " . $_POST["lastName"];
                $_SESSION["email"] = $_POST['email'];

            } catch (Exception $e) {
                echo "Error Creating Account! " . $e->getMessage();
            }
        }
    }

    $user = AccountManager::getConsultant($_SESSION["email"]);

    $isAccountHome = true;

} catch (Exception $e) {
    echo $e->getMessage();
}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Safety & Security Consultant Registry of Texas</title>
        <style type="text/css">
            @import "js/dojo/dojox/image/resources/image.css";
            @import "js/dojo/dijit/themes/tundra/tundra.css";
            @import "js/dojo/dojox/grid/resources/Grid.css";
            @import "js/dojo/dojox/grid/resources/tundraGrid.css";
        </style>
        <link href="styles/default.css"
              rel="stylesheet"
              type="text/css"
              media="all">
        <script src="js/dojo/dojo/dojo.js"
                type="text/javascript"
                djConfig="parseOnLoad:true">
        </script>
        <script src="js/default.js" type="text/javascript"></script>
        <script type="text/javascript">
            dojo.require("dojo.parser");
            dojo.require("dijit.layout.AccordionContainer");
            dojo.require("dijit.dijit");
            dojo.require("dojox.grid.DataGrid");
            dojo.require("dojo.data.ItemFileWriteStore");
            dojo.require("dijit.form.ValidationTextBox");
            dojo.require("dijit.form.Button");
            dojo.require("dijit.Dialog");
            dojo.require("dijit.form.CheckBox");
            dojo.require("dijit.ProgressBar");
            dojo.require("dijit.Dialog");

            dojo.addOnLoad(function () {

                dojo.connect(dijit.byId('tecLawDialog'), 'hide', function () {
                    document.body.style.overflow = "";
                });

                dojo.connect(dijit.byId('hbLawDialog'), 'hide', function () {
                    document.body.style.overflow = "";
                });
                
                managePublicProfileButtonImage_on = new Image ( );
                managePublicProfileButtonImage_off = new Image ( );

                managePublicProfileButtonImage_on.src = "images/buttons/manage_public_profile_in.png";
                managePublicProfileButtonImage_off.src = "images/buttons/manage_public_profile_out.png";

                editAccountSettingsButtonImage_on = new Image ( );
                editAccountSettingsButtonImage_off = new Image ( );

                editAccountSettingsButtonImage_on.src = "images/buttons/edit_account_settings_in.png";
                editAccountSettingsButtonImage_off.src = "images/buttons/edit_account_settings_out.png";

                searchPublicRegistryButtonImage_on = new Image ( );
                searchPublicRegistryButtonImage_off = new Image ( );

                searchPublicRegistryButtonImage_on.src = "images/buttons/search_public_registry_in2.png";
                searchPublicRegistryButtonImage_off.src = "images/buttons/search_public_registry_out2.png";
                
                refreshUserInformationLeftArea();
            });
        </script>
    </head>
    <body class="tundra">

        <?php
            include "includes/tecLawInclude.php";
            include "includes/hbLawInclude.php";
        ?>

        <table class="main">
            <thead>
                <tr class="mainHeader">
                    <th align="center">
                        <?php include "includes/topMenuInclude.php"; ?>
                    </th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td align="center" valign="top">
                        <table class="mainBody">
                            <tbody>
                                <tr style="height:15px;">
                                    <td style="width:175px;"></td>
                                    <td style="width:795px;"></td>
                                </tr>
                                <tr>
                                    <td valign="top">
                                        <?php include "includes/leftBarInclude.php"; ?>
                                    </td>
                                    <td valign="top" style="padding-left:20px;">
                                        <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                            <tbody>
                                                <tr>
                                                    <td class="pageMainTitle">
                                                        User Account Home
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="padding-top:10px;">
                                                        <div style="font-family:Verdana;font-size:12px;text-align:left;padding-right:10px;padding-top:10px;padding-left:10px;border: 1px solid #AAAAAA;">
                                                            
                                                                Welcome to the user account home page of the School Safety and
                                                                Security Consulting Services Registry of Texas.
                                                                This online resource is provided by the Texas School Safety
                                                                Center in accordance with <a href="javascript:showTecLaw();">TEC Sec. 37.2091</a>.
                                                            
                                                            <p>
                                                                The information provided on your profile will be made available
                                                                as an informational resource for school districts and institutions of higher education.
                                                                This registry should include anyone providing services to a school  district,
                                                                institution  of  higher  education,  district facility, or campus in the form of
                                                                advice, information, recommendations,  data  collection, or safety and security audit
                                                                services relevant  to  school  safety  and  security,  regardless  of whether the person
                                                                is paid for those services.
                                                            </p>
                                                            <p style="font-weight:bold;">
                                                                Inclusion of your information in this registry is not an indication of your qualifications
                                                                or ability to provide school safety or security consulting services, nor does it indicate the
                                                                Texas School Safety Center endorse your services.
                                                            </p>
                                                            <p style="font-weight:bold;">
                                                                Inclusion in this registry does not grant you permission to use the Texas School Safety Center
                                                                brand for promotional or advertisement purposes.
                                                            </p>
                                                            <p>
                                                                Anyone providing safety or security consulting services shall register with this tool in
                                                                accordance with <a href="javascript:showTecLaw();" style="white-space:nowrap;">TEC Sec. 37.2091</a> and <a href="javascript:showHBLaw();">H.B. 1831 Sec. 6.17</a>.
                                                            </p>
                                                            <p>
                                                                If you have any questions regarding this registry email please contact the Texas School Safety Center at (877) 304-2727
                                                                or by email at <a href="mailto:txssc@txstate.edu">txssc@txstate.edu</a>.
                                                            </p>
                                                        </div>
                                                        <div style="float:left;margin-top:20px;padding:10px 10px 10px 10px;font-family:Verdana;font-size:12px;text-align:left;border: 1px solid #AAAAAA;">
                                                            <div style="float:left;width:180px;">
                                                                <a href="userManageProfile.php">
                                                                    <img src="images/buttons/manage_public_profile_out.png"
                                                                         id="managePublicProfileButtonImage"
                                                                         name="managePublicProfileButtonImage"
                                                                         onmouseover="button_on('managePublicProfileButtonImage');"
                                                                         onmouseout="button_off('managePublicProfileButtonImage');"
                                                                         style="border:0px;"
                                                                         alt="managePublicProfile"/>
                                                                </a>
                                                            </div>
                                                            <div style="float:right;width:540px;">
                                                                The "<b>Manage Public Profile</b>" section allows you to create and edit your public profile information
                                                                and publish your information to the public registry.
                                                            </div>
                                                        </div>
                                                        <div style="float:left;margin-top:20px;padding:10px 10px 10px 10px;font-family:Verdana;font-size:12px;text-align:left;border: 1px solid #AAAAAA;">
                                                            <div style="float:left;width:180px;">
                                                                <a href="userManageAccount.php">
                                                                    <img src="images/buttons/edit_account_settings_out.png"
                                                                         id="editAccountSettingsButtonImage"
                                                                         name="editAccountSettingsButtonImage"
                                                                         onmouseover="button_on('editAccountSettingsButtonImage');"
                                                                         onmouseout="button_off('editAccountSettingsButtonImage');"
                                                                         style="border:0px;"
                                                                         alt="managePublicProfile"/>
                                                                </a>
                                                            </div>
                                                            <div style="float:right;width:540px;">
                                                                The "<b>Edit Account Settings</b>" section allows you to view and edit your user account information.
                                                            </div>
                                                        </div>
                                                        <div style="float:left;margin-top:20px;padding:10px 10px 10px 10px;font-family:Verdana;font-size:12px;text-align:left;border: 1px solid #AAAAAA;">
                                                            <div style="float:left;width:180px;">
                                                                <a href="searchConsultant.php">
                                                                    <img src="images/buttons/search_public_registry_out2.png"
                                                                         id="searchPublicRegistryButtonImage"
                                                                         name="searchPublicRegistryButtonImage"
                                                                         onmouseover="button_on('searchPublicRegistryButtonImage');"
                                                                         onmouseout="button_off('searchPublicRegistryButtonImage');"
                                                                         style="border:0px;"
                                                                         alt="managePublicProfile"/>
                                                                </a>
                                                            </div>
                                                            <div style="float:right;width:540px;">
                                                                The "<b>Search Public Registry</b>" section allows you to search the public registry and view the format in which your
                                                                information will be displayed to the public.
                                                            </div>
                                                        </div>
                                                    </td>
                                                </tr>
                                            </tbody>
                                        </table>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td align="center" valign="top">
                        <?php include "includes/mainFooterInclude.php"; ?>
                    </td>
                </tr>
            </tbody>
        </table>
    </body>
</html>
